package com.bmd.backgroundmanger.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

/**
 * <p>
 * 
 * </p>
 *
 * @author 坤哥
 * @since 2024-07-01
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("users")
@Schema(name = "User", description = "用户实体类")
@ContentRowHeight(18)//内容行高
@HeadRowHeight(25)//标题行高
@ColumnWidth(20)///列宽，可设置成员变量(属性)上
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

      @Schema(description = "用户ID")
      @TableId(value = "user_id", type = IdType.AUTO)
      @ExcelProperty(value = "用户ID",index = 0) //导出的数据 index:导出excel表的列的下标
      private Integer userId;

      @Schema(description = "用户名")
      @ExcelProperty(value = "用户名",index = 1)
      private String username;

      @Schema(description = "密码哈希")
      @ExcelProperty(value = "密码",index = 2)
      private String passwordHash;
      
      @Schema(description = "临时密码字段（用于接收前端数据）")
      @TableField(exist = false) // 不映射到数据库字段
      private String password;

      @Schema(description = "用户角色ID（临时字段，用于前端交互）")
      @TableField(exist = false) // 不映射到数据库字段
      private Integer roleId;

      @Schema(description = "用户角色名称（临时字段，用于前端显示）")
      @TableField(exist = false) // 不映射到数据库字段
      private String roleName;

      @Schema(description = "电子邮件")
      @ExcelProperty(value = "邮箱",index = 3)
      private String email;

      @Schema(description = "电话号码")
      @ExcelProperty(value = "电话",index = 4)
      private String phoneNumber;

      @Schema(description = "用户状态：1-启用，0-禁用")
      @TableField("status")
      @ExcelProperty(value = "状态",index = 5)
      private Integer status;

      @Schema(description = "个人头像URL")
      @ExcelIgnore //忽略导出的属性
      private String profilePictureUrl;

      @Schema(description = "创建人")
      @ExcelIgnore //忽略导出的属性
      private Integer createBy;

      @Schema(description = "创建时间")
      @ExcelProperty(value = "创建时间",index = 5)
      private LocalDateTime createTime;

      @Schema(description = "修改人")
      @ExcelIgnore //忽略导出的属性
      private Integer updateBy;

      @Schema(description = "修改时间")
      @ExcelIgnore //忽略导出的属性
      private LocalDateTime updateTime;
}
